package edu.neu.swc.commerce.feign.hystrix;

import com.alibaba.fastjson.JSON;
import edu.neu.swc.commerce.account.AddressInfo;
import edu.neu.swc.commerce.common.TableId;
import edu.neu.swc.commerce.feign.AddressClient;
import edu.neu.swc.commerce.vo.CommonResponse;
import lombok.extern.slf4j.Slf4j;
import org.apache.tomcat.jni.Address;
import org.springframework.stereotype.Component;

import java.util.Collections;

/**
 * <h1>账户服务熔断降级兜底策略</h1>
 */
@Slf4j
@Component
public class AddressClientHystrix implements AddressClient {
    @Override
    public CommonResponse<AddressInfo> getAddressInfoByTableId(TableId tableId) {
        log.error("[account client feign request error in roder service] get address info" +
                " error:[{}]", JSON.toJSONString(tableId));
        return new CommonResponse<>(
                -1,
                "account client feign request error in roder service",
                new AddressInfo(
                        -1L,
                        Collections.emptyList()
                )
        );
    }
}
